package com.atguigu.gmall.task.scheduled;

import com.atguigu.gmall.common.constant.MqConst;
import com.atguigu.gmall.common.service.RabbitService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.EnableScheduling;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;

@Component
@EnableScheduling
public class ScheduledTask {

    @Autowired
    private RabbitService rabbitService;

//    每天凌晨1点钟，秒，分，时,月，周，年？
    @Scheduled(cron = "0/5 * * * * ?")
    public void senMesag(){
        rabbitService.sendMessage(MqConst.EXCHANGE_DIRECT_TASK,  MqConst.ROUTING_TASK_1, "");
        System.out.println("");
    }

    @Scheduled(cron = "0 0 18 * * ?")
    public void clearRedis(){
        rabbitService.sendMessage(MqConst.EXCHANGE_DIRECT_TASK, MqConst.ROUTING_TASK_18, "");
        System.out.println("发送定时任务清楚秒杀缓存数据");
    }

}
